/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package GUI;

import Model.Gates.Composite;
import Model.Gates.Gate;
import java.awt.Dimension;
import java.awt.Point;
import java.util.ArrayList;
import javax.imageio.ImageIO;
import javax.swing.JOptionPane;

/**
 *
 * @author bg
 */
public class CompositeView extends AbstractElementView{

    Composite composite;
    protected ArrayList<AbstractElementView> element = new ArrayList<AbstractElementView>();
    protected ArrayList<WireView> wires = new ArrayList<WireView>();
    CompController compcontroller=null;

    public CompositeView(Composite composite, Point position) {
        this.position = position;
        inputs = new ArrayList<Point>();
        outputs = new ArrayList<Point>();
        try {
            img = ImageIO.read(getClass().getResource("Images/comp.png"));
        } catch (Exception e) {
            JOptionPane.showMessageDialog(null, e.getMessage());
        }
        this.composite = composite;
        this.position = position;
        this.preferredImageSize = new Dimension(30, 64);
        for (int i = Math.round(64 / (composite.getMaxInput() + 1)); i < 60; i += Math.round(64 / (composite.getMaxInput() + 1))) {
            inputs.add(new Point(position.x, position.y + i));
        }
        for (int i = Math.round(64 / (composite.getMaxOutput() + 1)); i < 60; i += Math.round(64 / (composite.getMaxOutput() + 1))) {
            outputs.add(new Point(position.x + 30, position.y + i));
        }
    }

    @Override
    Gate getGate() {
        return this.composite;
    }
    void addController(CompController c){
    compcontroller=c;
    }
}
